<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of MetricsController
 *
 * @author QuangKhoi
 */
class MetricsController {
    //put your code here
    public $model;
    /**
     *
     * @var MetricsView
     */
    public $view;
    
    public function __construct($model, $view) {
        $this->model = $model;
        $this->view = $view;
    }
    
    /**
     * 
     * @param Filter $stream
     */
    public function render($filter) {
        //Create NuSOAP client
        $client = new nusoap_client("http://localhost/buzzPulse/m/");
        
        //get topSocialPlatformData
        $topSocialPlatformsData = $client->call("getTopSocialPlatformsData", array("filter" => $filter));
        $this->view->topSocialPlatformsData = $topSocialPlatformsData;
        
        //get sharingMetricsData
        $sharingMetricsData = $client->call("getSharingMetricsData", array("filter" => $filter));
        $this->view->sharingMetricsData = $sharingMetricsData;
        
        //get sentimentData
        $sentimentData = $client->call("getSentimentData", array("filter" => $filter));
        $this->view->sentimentData = $sentimentData;
        
        //get genderDistributionData
        $genderDistributionData = $client->call("getGenderDistributionData", array("filter" => $filter));
        $this->view->genderDistributionData = $genderDistributionData;
        
        //get topLanguagesData
        $topLanguagesData = $client->call("getTopLanguagesData", array("filter" => $filter));
        $this->view->topLanguagesData = $topLanguagesData;
        
        //get geographicDistributionData
        $geographicDistributionData = $client->call("getGeographicDistributionData", array("filter" => $filter));
        $this->view->geographicDistributionData = $geographicDistributionData;
        
        //get exposureData
        $exposureData = $client->call("getExposureData", array("filter" => $filter));
        $this->view->exposureData = $exposureData;
        
        //get conversationMapData
        $conversationMapData = $client->call("getConversationMapData", array("filter" => $filter));
        $this->view->conversationMapData = $conversationMapData;
        
        $streamView = new StreamView();
        $streamView->model = Stream::withId($filter["streamId"]);
        $masterView = MasterView::getInstance();
        $masterView->metrics = $this->model;
        $masterView->streamView = $streamView;
        
        $masterView->metricsView = $this->view;
        
    }
}

?>
